package com.ruoyi.spin.service.impl;

import com.ruoyi.spin.domain.SpinCoinBean;
import com.ruoyi.spin.mapper.SpinCoinBeanMapper;
import com.ruoyi.spin.service.ISpinCoinBeanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 抓取的SpinCoin数据Service业务层处理
 *
 * @author stay
 * @date 2023-01-14
 */
@Service
public class SpinCoinBeanServiceImpl implements ISpinCoinBeanService {
  @Autowired private SpinCoinBeanMapper spinCoinBeanMapper;

  /**
   * 查询抓取的SpinCoin数据
   *
   * @param id 抓取的SpinCoin数据主键
   * @return 抓取的SpinCoin数据
   */
  @Override
  public SpinCoinBean selectSpinCoinBeanById(Long id) {
    return spinCoinBeanMapper.selectSpinCoinBeanById(id);
  }

  /**
   * 查询抓取的SpinCoin数据列表
   *
   * @param spinCoinBean 抓取的SpinCoin数据
   * @return 抓取的SpinCoin数据
   */
  @Override
  public List<SpinCoinBean> selectSpinCoinBeanList(SpinCoinBean spinCoinBean) {
    return spinCoinBeanMapper.selectSpinCoinBeanList(spinCoinBean);
  }

  /**
   * 新增抓取的SpinCoin数据
   *
   * @param spinCoinBean 抓取的SpinCoin数据
   * @return 结果
   */
  @Override
  public int insertSpinCoinBean(SpinCoinBean spinCoinBean) {
    return spinCoinBeanMapper.insertSpinCoinBean(spinCoinBean);
  }

  /**
   * 修改抓取的SpinCoin数据
   *
   * @param spinCoinBean 抓取的SpinCoin数据
   * @return 结果
   */
  @Override
  public int updateSpinCoinBean(SpinCoinBean spinCoinBean) {
    return spinCoinBeanMapper.updateSpinCoinBean(spinCoinBean);
  }

  /**
   * 批量删除抓取的SpinCoin数据
   *
   * @param ids 需要删除的抓取的SpinCoin数据主键
   * @return 结果
   */
  @Override
  public int deleteSpinCoinBeanByIds(Long[] ids) {
    return spinCoinBeanMapper.deleteSpinCoinBeanByIds(ids);
  }

  /**
   * 删除抓取的SpinCoin数据信息
   *
   * @param id 抓取的SpinCoin数据主键
   * @return 结果
   */
  @Override
  public int deleteSpinCoinBeanById(Long id) {
    return spinCoinBeanMapper.deleteSpinCoinBeanById(id);
  }

  @Override
  @Transactional(rollbackFor = Exception.class)
  public int updateAll(List<SpinCoinBean> data) {
    data.forEach(a -> spinCoinBeanMapper.insertSpinCoinBean(a));
    return 1;
  }
}
